import { createRouter, createWebHistory } from 'vue-router';
import Login from '../components/Login.vue';
import Dashboard from '../views/Dashboard.vue';

const routes = [
  {
     path:'/',
            component:()=>import("../components/login.vue"),
            name:"login"
  },
  {
    path: '/dashboard',
    component:()=>import("../views/Dashboard.vue"),
    name:"dashboard"
  }
];

const router = createRouter({
  history: createWebHistory(),
  routes
});


router.beforeEach((to, from, next) => {
  if (to.meta.requiresAuth) {
    next('/');
  } else {
    next();
  }
});

export default router;